/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package olympicgameslogic;

import java.io.Serializable;

/**
 *
 * @author Nuno
 */
public abstract class Medal implements Serializable, Comparable<Medal> {

   public static enum MEDALTYPE {

      GOLD, SILVER, BRONZE
   };
   public static Medal.MEDALTYPE[] medals = {Medal.MEDALTYPE.GOLD, Medal.MEDALTYPE.SILVER, Medal.MEDALTYPE.BRONZE};
   public static int[] medalsValues = {3, 2, 1};
   private EditionDisciplineEvent editionDisciplineEvent;
   private MEDALTYPE medalType;

   public Medal(EditionDisciplineEvent editionDisciplineEvent, MEDALTYPE medalType) {


      this.medalType = medalType;
      this.editionDisciplineEvent = editionDisciplineEvent;
   }

   /**
    * @return the modality
    */
   public Modality getModality() {
      return editionDisciplineEvent.getDiscipline().getModality();
   }

   /**
    * @return the discipline
    */
   public Discipline getDiscipline() {
      return editionDisciplineEvent.getEditionDisciplineEvent().getEventDiscipline();
   }

   /**
    * @return the edition
    */
   public Edition getEdition() {
      return editionDisciplineEvent.getEdition();
   }

   /**
    * @return the medalType
    */
   public MEDALTYPE getMedalType() {
      return medalType;
   }

   /**
    * @param medalType the medalType to set
    */
   public void setMedalType(MEDALTYPE medalType) {
      this.medalType = medalType;
   }

   /**
    * @return the editionDisciplineEvent
    */
   public EditionDisciplineEvent getEditionDisciplineEvent() {
      return editionDisciplineEvent;
   }

   /**
    * @param editionDisciplineEvent the editionDisciplineEvent to set
    */
   public void setEditionDisciplineEvent(EditionDisciplineEvent editionDisciplineEvent) {
      this.editionDisciplineEvent = editionDisciplineEvent;
   }

   @Override
   public String toString() {
      return getModality().getName() + " " + getDiscipline().getName() + " " + this.medalType.toString();
   }

   public static Medal.MEDALTYPE getMedal(int i) {
      return medals[i];
   }

   public boolean isTeamMedal() {
      if (this instanceof MedalTeam)
	 return true;
      else
	 return false;
   }
}
